<?php include_once '../../../include/inc_session.php';

	if(isset($_GET['Identifiant_personne']) && !empty($_GET['Identifiant_personne']))
	{ // Vérifier si Identifiant_personne est passé en paramètre
		$idPersonne = $_GET['Identifiant_personne'];
	}
	$idRole = isset($_POST['idrole'])? $_POST['idrole']: $_GET['idrole'];
	$idContrat = isset($_POST['idcontrat'])? $_POST['idcontrat']: $_GET['idcontrat'];
	
	$idRefExt = isset($_POST['Identifiant_refext'])? $_POST['Identifiant_refext']: $_GET['Identifiant_refext'];
	
	$oRefExt = new dataObject_refExterne($idRefExt);
	
	$TYPE    =  (isset($_POST['Type_refexterne']))  ?  $_POST['Type_refexterne']  : $oRefExt->_TYPE_REFEXT;
	$VALEUR    =  (isset($_POST['ORE_Valeur_refexterne'])) ?  $_POST['ORE_Valeur_refexterne'] : $oRefExt->_VALEUR_REFEXT;
	
	if ($gbFormValid) 
	{
		$oRefExt->_TYPE_REFEXT 			= $TYPE;
		$oRefExt->_VALEUR_REFEXT 			= $VALEUR;
		$oRefExt->_IDENTIFIANT_PERSONNE 	= $_POST['Identifiant_personne'];
		$oRefExt->_IDENTIFIANT_ROLE 		= $idRole;
		$oRefExt->_IDENTIFIANT_CONTRAT 	= $idContrat;
		
		$id = $oRefExt->refExterne_update();
		
		if($id===false) $oForm->ajouterErreur(chgmt_couv_mod_refext_pbm);
		else $oForm->ajouterErreur(refexterne_modif);
		//header("location:index.php?Identifiant_personne=".$idPersonne);
	}
	
	$nom_module_saisie="Détail référence externe";
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=8" />
			<title>Modification référence externe</title>
			<link rel="stylesheet" type="text/css" href="../../../css/main.css" />
            <link rel="stylesheet" type="text/css" href="list.css" />
			<!--[if IE 7]>
            	<link rel="stylesheet" type="text/css" href="../../css/ie7.css" />
            	<link rel="stylesheet" type="text/css" href="form_ie7.css" />
            <![endif]-->
	</head>
<body>
<div id="sf_menu1">
	<h3><?php echo $oBloc->_MENU_NOM ?></h3>
	<div id="information_erreur" class="false">
        <ul id="message">
        	<li><?php $aMsg =$oForm->getValidMessage(); echo (!empty($aMsg))? $aMsg[0]['message'] : ''; ?></li>
        </ul>
    </div>
</div>


<div class="corps1">
<div class="cleared"></div>
<div id="br"></div>
<!--/***************************************/-->

<form action="<?php echo $sEditFormAction; ?>" method="post" name="form1" id="form1">
	<div class="imgleft"></div>
	<div class="imgmiddle">
    <div class="btn">
    	<span class="btnleft"></span>
        <span class="btnmiddle">
        	<h5><?php echo $oFonction->_MENU_AFFICHE; ?></h5>
        </span><span class="btnright"></span>
    </div>
  	<div class="btn1">
    	<span class="btnleft"></span>
        <span class="btnmiddle">
        	<h5><?php echo $nom_module_saisie; ?></h5>
        </span>
        <span class="btnright"></span>
    </div>
	<div class="formulaire">
  <table class="tabform">
    <tr>
      <td class="td0">TYPE </td>
      <td><select name="Type_refexterne">
	<?php 
	$aListType = dataObject_elementdico::elementdico_getListFromCode(dataObject_dictionnaire::_TYPE_REF_EXTERNE);
	foreach ($aListType as $i => $aRow)
	{ ?>
		<option value="<?php echo $aRow['Code_element']; ?>" <?php if(isset($_POST['Type_refexterne'])){if (!(strcmp($aRow['Code_element'], htmlentities($_POST['Type_refexterne'], ENT_COMPAT, 'utf-8')))) {echo "SELECTED";}}else{ if (!(strcmp($aRow['Code_element'], htmlentities($oRefExt->_TYPE_REFEXT, ENT_COMPAT, 'utf-8')))) {echo "SELECTED";}} ?> ><?php echo $aRow['Nom_element']; ?></option>
	<?php 
	} ?>
      </select>
      </td>
    </tr>
    <tr>
      <td class="td0">VALEUR</td>
      <td><input type="text" name="ORE_Valeur_refexterne" value="<?php if(isset($_POST['ORE_Valeur_refexterne'])){ echo remind_text('ORE_Valeur_refexterne'); }else{ echo htmlentities($oRefExt->_VALEUR_REFEXT, ENT_COMPAT, 'utf-8');} ?>" size="32" maxlength="30" /></td>
    </tr>
    
    <input type="hidden" name="Identifiant_personne" value="<?php echo $idPersonne;?>" />
  <input type="hidden" name="idrole" value="<?php echo $idRole;?>" />
  <input type="hidden" name="idcontrat" value="<?php echo $idContrat;?>" />
  </table>
    </div>
</div>
<div class="imgright"></div>				
<div class="cleared"></div>

<div class="bt1">
	<a href="../refexterne/index.php?Identifiant_personne=<?php echo$idPersonne; ?>&idcontrat=<?php echo $idContrat; ?>&idrole=<?php echo $idRole; ?>">
    	<span class="btleft"></span>
        <span class="btmiddle">Annuler</span>
        <span class="btright"></span>
    </a>
</div>

<div class="bt">
	<span class="btleft"></span>
    <input type="submit" name="Valider" value="Valider" class="resizeall btmiddle"/>
    <span class="btright"></span>
</div>
    
<div class="cleared"></div>

  <input type="hidden" name="MM_update" value="form1" />
  <input type="hidden" name="Identifiant_refext" value="<?php echo $oRefExt->_IDENTIFIANT_REFEXT; ?>" />
</form>
 </div>
</body>
</html>
<?php

include_once PATH_INCLUDE.'inc_pied_page.php';
?>